package calcmaster.calculator.util;

public final class Maths {
	
	public static final double PI12 = 1.57079632679489661923;

    public static final double PI32 = 4.71238898038468985769;

    public static final double PI2 = 6.28318530717958647692;
    
    
    public static double arccosh(double a) {
        return StrictMath.log(a + StrictMath.sqrt(a * a - 1.0));
    }
    
    public static double arcctg(double a) {
        return PI12 - StrictMath.atan(a);
    }
    
    public static double arccoth(double a) {
        return StrictMath.log((a + 1.0) / (a - 1.0)) * 0.5;
    }
    
    public static double arcsinh(double a) {
        return StrictMath.log(a + StrictMath.sqrt(a * a + 1.0));
    }
    
    public static double artanh(double a) {
        return StrictMath.log((1.0 + a) / (1.0 - a)) * 0.5;
    }
    
    public static double ctg(double a) {
        return StrictMath.tan(PI12 - a);
    }
    
    public static double coth(double a) {
        return 1.0 / StrictMath.tanh(a);
    }
    
    public static double div(double a, double b) {
    	return ((long) a) / ((long) b);
    }
    
    public static double degreeToGrads(double a) {
        return a * 200.0 / 180.0;
    }
    
    public static double frac(double a) {
        return a - (long) a;
    } 
    
    public static double gradsToDegree(double a) {
        return a * 180.0 / 200.0;
    }
    
    public static double gradsToRadians(double a) {
        return a * StrictMath.PI / 200.0;
    }
    
    public static double log(double a, double b) {
        return StrictMath.log(a) / StrictMath.log(b);
    }
    
    public static double randomn(double a) {
        return StrictMath.random() * a;
    }

    public static double randomr(double a, double b) {
        if(a >= b)
            return 0.0;
        return StrictMath.random() * (b - a) + a;
    }
    
    public static double radiansTogGrads(double a) {
        return a * 200.0 / StrictMath.PI;
    }
    
}
